<template>
  <div class="singerList">
    <div class="fliter">
      <div class="language fliterItem">
        语种：
        <span
          v-for="(l, index) in languageList"
          :key="index"
          :class="{ active: l === param.language }"
          @click="changeFliter('language', l, index)"
        >
          {{ l }}
        </span>
      </div>
      <div class="classify fliterItem">
        分类：
        <span
          v-for="(c, index) in classifyList"
          :key="index"
          :class="{ active: c === param.classify }"
          @click="changeFliter('classify', c, index)"
        >
          {{ c }}
        </span>
      </div>
      <div class="screen fliterItem">
        筛选：
        <span
          v-for="(s, index) in screenList"
          :key="index"
          :class="{ active: s === param.screen }"
          @click="changeFliter('screen', s, index)"
        >
          {{ s }}
        </span>
      </div>
    </div>
    <div class="singer">
      <el-card
        :body-style="{ padding: '0px' }"
        style="width: 150px"
        v-for="(artist, i) in artists"
        :key="i"
        @click.native="toSinger(artist)"
      >
        <img :src="artist.picUrl" class="image" />
        <div style="padding: 14px">
          <span>{{ artist.name }}</span>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "singerListPage",

  data() {
    return {
      param: {
        language: "全部",
        classify: "全部",
        screen: "热门",
      },
      languageList: ["全部", "华语", "欧美", "日本", "韩国", "其他"],
      languageListCode: ["-1", "7", "96", "8", "16", "0"],
      classifyList: ["全部", "男歌手", "女歌手", "乐队组合"],
      classifyListCode: ["-1", "1", "2", "3"],
      screenList: [
        "热门",
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "k",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z",
        "#",
      ],
      screenListCode: [
        "-1",
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "k",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z",
        "0",
      ],
      artists: null,
    };
  },
  created() {
    axios
      .get(
        "https://apis.netstart.cn/music/artist/list?limit=60&type=-1&area=-1&initial=-1"
      )
      .then((res) => {
        this.artists = res.data.artists;
        console.log(res.data.artists);
      });
  },
  mounted() {},

  methods: {
    changeFliter(key, o) {
      this.param[key] = o;
      let i = this.languageList.findIndex((item) => {
        return item === this.param.language;
      });
      let area = this.languageListCode[i];

      let j = this.classifyList.findIndex((item) => {
        return item === this.param.classify;
      });
      let type = this.classifyListCode[j];

      let k = this.screenList.findIndex((item) => {
        return item === this.param.screen;
      });
      let initial = this.screenListCode[k];
      console.log(type, area, initial);

      axios
        .get(
          `https://apis.netstart.cn/music/artist/list?limit=60&type=${type}&area=${area}&initial=${initial}`
        )
        .then((res) => {
          this.artists = res.data.artists;
          console.log(res.data.artists);
          
        });
    },
    toSinger(artist) {
      this.$router.push("/home/singer/" + artist.id);
    },
  },
};
</script>

<style lang="scss" scoped>
.singerList {
  color: #ffffff;
  padding: 20px;

  .fliterItem {
    margin: 10px 0;

    span {
      font-size: 12px;
      padding: 0 10px;
      text-align: center;
      &.active {
        color: #ffffff;
        background-color: rgba($color: #f88080, $alpha: 0.4);
        border-radius: 20px;
      }
    }
  }

  .singer {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    flex-wrap: wrap;
    height: 400px;
    overflow-y: auto;

    &::-webkit-scrollbar {
      /*滚动条整体样式*/
      width: 1px;
    }

    &::-webkit-scrollbar-thumb {
      /*滚动条里面小方块*/
      border-radius: 10px;
      // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      // background-color: #f90;
      // background-image: -webkit-linear-gradient(
      //     45deg,
      //     rgba(255, 255, 255, 0.2) 25%,
      //     transparent 25%,
      //     transparent 50%,
      //     rgba(255, 255, 255, 0.2) 50%,
      //     rgba(255, 255, 255, 0.2) 75%,
      //     transparent 75%,
      //     transparent
      // );
    }

    &::-webkit-scrollbar-track {
      /*滚动条里面轨道*/
      // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      // background: #ededed;
    }

    .el-card {
      margin-top: 10px;

      &:hover {
        background-color: #f88080;
        color: #ffffff;
      }
    }

    .name {
      font-size: 13px;
      color: #999;
    }

    .image {
      width: 100%;
      display: block;
    }
  }
}
</style>